﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public static partial class msg
    {
        public static dynamic getDiscuss(int did)
        {
            var sql = new Sql.SqlDataContext();
            var d = sql.Discuss.FirstOrDefault(row => row.did == did);
            if (d == null) return new
                {
                    success = false,
                    msg = "帖子不存在"
                };
            var u = sql.User.First(row => row.username == d.username);
            var p = sql.Problem.First(row => row.pid == d.pid);
            return new
            {
                success = true,
                d.parentDid,
                d.did,
                d.title,
                d.username,
                u.nickname,
                time = d.time.toTimeString(),
                d.content,
                d.pid,
                problemTitle = p.title
            };
        }
    }
}